package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class TravelDiscuss {
    private Long id;

    private Travel travel;  //评论的游记

    private User source;    //评论的用户

    private String content; //评论的内容

    private Integer type = 0;//已读,未读
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date time;  //评论时间


    public String getJsonString(){
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id",id);
        map.put("travel.id",travel.getId());
        map.put("travel.title",travel.getTitle());
        map.put("source.id",source.getId());
        map.put("source.nickName",source.getNickName());
        map.put("content",content);
        map.put("type",type);
        return JSONUtils.toJSONString(map);
    }
}